package com.mm.dictionary.utils.translate;

import cn.hutool.json.JSONUtil;


/**
 * @BelongsProject: 9.English_英汉词典
 * @BelongsPackage: com.example.english_英汉词典.utils
 * @Author : 游在海里的鱼
 * @CreateTime : 2024-05-14  01:24
 * @Version : 1.0
 * @ClassName : TODO
 * @Description : TODO
 */
public class WordUtils {

    public static String translate(String word){
        词条 translate = 英汉词典.查词(word);
        if(translate == null){
            translate = 英汉词典.查词(word.toLowerCase());
        }
        if(translate == null){
            return "";
        }
        return JSONUtil.toJsonStr(translate.中文释义);
    }
    public static String phonetic(String word){
        词条 translate = 英汉词典.查词(word);
        if(translate == null){
            translate = 英汉词典.查词(word.toLowerCase());
        }
        if(translate == null){
            return null;
        }
        return translate.音标;
    }

    public static String NNPTransition(String word,String nature){
        if(word.charAt(0) >= 'A' || word.charAt(0) <= 'Z'){
            if(!nature.equals("NNP") && !word.equals("I")){
                return word.toLowerCase();
            }
        }
        return word;
    }
}
